package com.zkthink.ceres.promotion.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.zkthink.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 营销活动表
 * </p>
 *
 * @author kellen
 * @since 2020-06-16
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "ceres_promotion",autoResultMap=true)
@ApiModel(value = "Promotion", description = "营销活动表")
@AllArgsConstructor
public class Promotion extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 活动名称
     */
    @ApiModelProperty(value = "活动名称")
    @NotEmpty(message = "活动名称不能为空")
    @Length(max = 200, message = "活动名称长度不能超过200")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "活动名称")
    private String name;

    /**
     * 活动图片
     */
    @ApiModelProperty(value = "活动图片")
    @NotEmpty(message = "活动图片不能为空")
    @Length(max = 500, message = "活动图片长度不能超过500")
    @TableField(value = "image", condition = LIKE)
    @Excel(name = "活动图片")
    private String image;

    /**
     * 描述
     */
    @ApiModelProperty(value = "描述")
    @NotEmpty(message = "描述不能为空")
    @Length(max = 1000, message = "描述长度不能超过1000")
    @TableField(value = "description", condition = LIKE)
    @Excel(name = "描述")
    private String description;

    /**
     * 活动状态 1-报名未开始 2-报名已开始 3-报名已结束 4-活动已开始 5-活动已结束
     */
    @ApiModelProperty(value = "活动状态 1-报名未开始 2-报名已开始 3-报名已结束 4-活动已开始 5-活动已结束")
    @NotNull(message = "活动状态不能为空，默认为1")
    @TableField("status")
    @Excel(name = "活动状态")
    private Integer status;

    /**
     * 报名开始时间
     */
    @ApiModelProperty(value = "报名开始时间")
    @NotNull(message = "报名开始时间不能为空")
    @TableField("apply_start_time")
    @Excel(name = "报名开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime applyStartTime;

    /**
     * 报名结束时间
     */
    @ApiModelProperty(value = "报名结束时间")
    @NotNull(message = "报名结束时间不能为空")
    @TableField("apply_end_time")
    @Excel(name = "报名结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime applyEndTime;

    /**
     * 活动开始时间
     */
    @ApiModelProperty(value = "活动开始时间")
    @NotNull(message = "活动开始时间不能为空")
    @TableField("activity_start_time")
    @Excel(name = "活动开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime activityStartTime;

    /**
     * 活动结束时间
     */
    @ApiModelProperty(value = "活动结束时间")
    @NotNull(message = "活动结束时间不能为空")
    @TableField("activity_end_time")
    @Excel(name = "活动结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime activityEndTime;

    /**
     * 是否需要保证金 0否 1是
     */
    @ApiModelProperty(value = "是否需要保证金 0否 1是")
    @NotNull(message = "是否需要保证金 0否 1是不能为空")
    @TableField("is_need_security_deposit")
    @Excel(name = "是否需要保证金 0否 1是")
    private Integer isNeedSecurityDeposit;

    /**
     * 保证金金额
     */
    @ApiModelProperty(value = "保证金金额")
    @NotNull(message = "保证金金额不能为空")
    @TableField("security_deposit")
    @Excel(name = "保证金金额")
    private Long securityDeposit;

    /**
     * 活动标签
     */
    @ApiModelProperty(value = "活动标签")
    @Length(max = 100, message = "活动标签长度不能超过100")
    @TableField(value = "tag", condition = LIKE)
    @Excel(name = "活动标签")
    private String tag;

    /**
     * 优惠方式 1满减 2优惠券
     */
    @ApiModelProperty(value = "优惠方式 1满减 2优惠券")
    @NotNull(message = "优惠方式 1满减 2优惠券不能为空")
    @TableField("promotion_type")
    @Excel(name = "优惠方式 1满减 2优惠券")
    private Integer promotionType;

    /**
     * 优惠方案 1叠加优惠 2阶梯优惠
     */
    @ApiModelProperty(value = "优惠方案 1叠加优惠 2阶梯优惠")
    @NotNull(message = "优惠方案 1叠加优惠 2阶梯优惠不能为空")
    @TableField("promotion_plan")
    @Excel(name = "优惠方案 1叠加优惠 2阶梯优惠")
    private Integer promotionPlan;

    /**
     * 优惠详情，json数组
     */
    @ApiModelProperty(value = "优惠详情，json数组")
    @NotEmpty(message = "优惠详情，json数组不能为空")
    @Length(max = 2000, message = "优惠详情，json数组长度不能超过2000")
    @TableField(value = "promotion_detail",typeHandler = FastjsonTypeHandler.class)
    @Excel(name = "优惠详情，json数组")
    private List<Map<String,Object>> promotionDetail;

    /**
     * 是否删除0否 1是
     */
    @ApiModelProperty(value = "是否删除0否 1是")
    @NotNull(message = "是否删除0否 1是不能为空")
    @TableField("is_delete")
    @Excel(name = "是否删除0否 1是")
    @TableLogic
    private Integer isDelete;


    @Builder
    public Promotion(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser, 
                    String name, String image, String description, LocalDateTime applyStartTime, LocalDateTime applyEndTime, 
                    LocalDateTime activityStartTime, LocalDateTime activityEndTime, Integer isNeedSecurityDeposit, Long securityDeposit, String tag, Integer promotionType,
                    Integer promotionPlan, List<Map<String,Object>> promotionDetail, Integer isDelete) {
        this.id = id;
        this.createTime = createTime;
        this.createUser = createUser;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.name = name;
        this.image = image;
        this.description = description;
        this.applyStartTime = applyStartTime;
        this.applyEndTime = applyEndTime;
        this.activityStartTime = activityStartTime;
        this.activityEndTime = activityEndTime;
        this.isNeedSecurityDeposit = isNeedSecurityDeposit;
        this.securityDeposit = securityDeposit;
        this.tag = tag;
        this.promotionType = promotionType;
        this.promotionPlan = promotionPlan;
        this.promotionDetail = promotionDetail;
        this.isDelete = isDelete;
    }

}
